#pragma once

#include <windows.h>

#include <gl/gl.h>
#include <gl/glu.h>

#include <glext/wglext.h>
#include <glext/glext.h>

#pragma comment(lib,"OpenGL32.lib")
#pragma comment(lib,"glu32.lib")

#include "Math/Math3D.h"

void GL_GetViewport( GLvec3f& vp );
void GL_GetUpVec( GLmat4f& m, GLvec3f& up );
void GL_GetPosVec( GLmat4f& m, GLvec3f& pos );
void GL_GetRightVec( GLmat4f& m, GLvec3f& right );
void GL_GetForwardVec( GLmat4f& m, GLvec3f& forward );
void GL_GetModelViewMatrix( GLmat4f& m );
void GL_GetProjectMatrix( GLmat4f& m );

typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0);

extern PFNGLLOCKARRAYSEXTPROC  glLockArraysEXT;
extern PFNGLUNLOCKARRAYSEXTPROC   glUnlockArraysEXT;
extern PFNGLACTIVETEXTUREARBPROC       glActiveTextureARB;
extern PFNGLCLIENTACTIVETEXTUREARBPROC     glClientActiveTextureARB;

extern PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB;
extern PFNGLMULTITEXCOORD2FVARBPROC glMultiTexCoord2fvARB;
extern PFNGLMULTITEXCOORD3FARBPROC glMultiTexCoord3fARB;
extern PFNGLMULTITEXCOORD3FVARBPROC glMultiTexCoord3fvARB;

extern PFNGLUNIFORM1FPROC glUniform1f;
extern PFNGLUNIFORM2FPROC glUniform2f;
extern PFNGLUNIFORM3FPROC glUniform3f;
extern PFNGLUNIFORM4FPROC glUniform4f;
extern PFNGLUNIFORM1IPROC glUniform1i;

extern PFNGLUNIFORM1UIEXTPROC glUniform1uiEXT;
extern PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB;
extern PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB;
extern PFNGLSHADERSOURCEARBPROC glShaderSourceARB;
extern PFNGLCOMPILESHADERARBPROC glCompileShaderARB;
extern PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB;
extern PFNGLGETINFOLOGARBPROC glGetInfoLogARB;
extern PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB;
extern PFNGLATTACHOBJECTARBPROC glAttachObjectARB;
extern PFNGLLINKPROGRAMARBPROC glLinkProgramARB;
extern PFNGLDELETEOBJECTARBPROC glDeleteObjectARB;
extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
extern PFNGLUNIFORM1UIEXTPROC glUniform1uiEXT;
extern PFNGLUNIFORMMATRIX2FVPROC glUniformMatrix2fvARB;
extern PFNGLUNIFORMMATRIX3FVPROC glUniformMatrix3fvARB;
extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fvARB;

extern PFNGLWEIGHTFVARBPROC glWeightfvARB;
extern PFNGLWEIGHTPOINTERARBPROC glWeightPointerARB;
extern PFNGLVERTEXBLENDARBPROC glVertexBlendARB;

extern PFNGLVERTEXATTRIB1FARBPROC glVertexAttrib1fARB;
extern PFNGLVERTEXATTRIB2FARBPROC glVertexAttrib2fARB;
extern PFNGLVERTEXATTRIB3FARBPROC glVertexAttrib3fARB;
extern PFNGLVERTEXATTRIB4FARBPROC glVertexAttrib4fARB;
extern PFNGLVERTEXATTRIBPOINTERARBPROC glVertexAttribPointerARB;
extern PFNGLENABLEVERTEXATTRIBARRAYARBPROC glEnableVertexAttribArrayARB;
extern PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glDisableVertexAttribArrayARB;
extern PFNGLBINDATTRIBLOCATIONARBPROC glBindAttribLocationARB;
extern PFNGLGETACTIVEATTRIBARBPROC glGetActiveAttribARB;
extern PFNGLGETATTRIBLOCATIONARBPROC glGetAttribLocationARB;

void GL_BeginArray( GLvec3f* pos,GLvec3f*nrm,GLvec2f*tc,GLvec4f*vc );
void GL_DrawTriListArray( unsigned int* indices,int size );
void GL_DrawTriStripArray( unsigned int* indices,int size );
void GL_EndArray();
